package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.pinyoumei.app.R;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Walter on 2020-08-11.
 */
public class SourceMaterialImageRecycleAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private List<String> data;

    public SourceMaterialImageRecycleAdapter(@Nullable List<String> data) {
        super(R.layout.item_item_source_image, data);
        this.data = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView iv = helper.getView(R.id.item_item_source_iv);
        if (item.equals(""))
            return;
        Glide.with(mContext).load(item).into(iv);
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null)
                    listener.imageClick(item);
            }
        });
    }

    public void setListener(SourceMaterialListener listener) {
        this.listener = listener;
    }

    public SourceMaterialListener listener;

    public interface SourceMaterialListener {
        void imageClick(String url);
    }
}
